package model

func init() {
	Handle.Register("team", RoleTeam{})
}

type Team struct {
	//Type    int32  `json:"type" bson:"type"`
	Name string            `json:"name" bson:"name"`
	List map[string]string `json:"list" bson:"list"` //目前不清楚K V都是什么
	//GroupID int32  `json:"groupId" bson:"groupId"`
}

type TeamList map[string]string

type RoleTeam map[string]*Team

//type RoleTeamList map[string]TeamList

func (r RoleTeam) Get(key string) *Team {
	if r == nil {
		return nil
	}
	v, ok := r[key]
	if !ok {
		return nil
	}
	v2 := *v
	return &v2

}

func (rt RoleTeam) getter(r *Role, k string) (any, bool) {
	return rt.Get(k), true
}
func (rr RoleTeam) setter(r *Role, k string, v any) (any, bool) {
	if r.Team == nil {
		r.Team = RoleTeam{}
	}
	rv := v.(*Team)
	r.Team[k] = rv
	return rv, true
}

//func (rt RoleTeamList) getter(r *Role, name string) (any, bool) {
//	if r == nil {
//		return nil, true
//	}
//	data, ok := r.TeamList[name]
//	if !ok {
//		return nil, true
//	}
//	tl := TeamList{}
//	for k, v := range data {
//		tl[k] = v
//	}
//	return tl, true
//}
//func (rr RoleTeamList) setter(r *Role, k string, v any) (any, bool) {
//	if r.TeamList == nil {
//		r.TeamList = RoleTeamList{}
//	}
//	rv := v.(TeamList)
//	r.TeamList[k] = rv
//	return rv, true
//}
